关于Python安装PyQT5相关库PyQT5

您所在的位置:网站首页 python pyqt5安装不了 关于Python安装PyQT5相关库PyQT5

关于Python安装PyQT5相关库PyQT5

2023-04-13 02:21| 来源: 网络整理| 查看: 265

最近想要用Python做界面程序的开发,研究了下,主流是使用PyQT5相关库来开发,于是就开始了PyQT5相关库的安装。本以为安装一个库而已,这不是Python开发者手到擒来的事吗,so easy啦!

但是,结果却是,一直报错安装不了!!!

在PyCharm集成环境安装报错如下:

ERROR: Could not find a version that satisfies the requirement pyqt5-tools (from versions: none)

在终端执行命令执行报错如下:

E:\PythonProject> pip install pyqt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting pyqt5-tools Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b7/70/a25aab849a5e38ae78716acde1f917a14d9d819c8600bbb8cf536781f7c5/pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB) Requirement already satisfied: click in c:\users\谢强华\appdata\local\programs\python\python310\lib\site-packages (from pyqt5-tools) (8.1.3) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/36/b8/a255b8160e863678aa7d559a4c8c33b5448a6e270992d1464ec9f87ed633/pyqt5_tools-5.15.4.3.1-py3-none-any.whl (28 kB) Collecting python-dotenv Using cached https://pypi.tuna.tsinghua.edu.cn/packages/30/5f/2e5c564bd86349fe6b82ca840f46acf6f4bb76d79ba9057fce3d3e008864/python_dotenv-0.20.0-py3-none-any.whl (17 kB) Collecting pyqt5==5.15.4 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/8e/a4/d5e4bf99dd50134c88b95e926d7b81aad2473b47fde5e3e4eac2c69a8942/PyQt5-5.15.4.tar.gz (3.3 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [29 lines of output] Traceback (most recent call last): File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 156, in prepare_metadata_for_build_wheel hook = backend.prepare_metadata_for_build_wheel AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in main() File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 160, in prepare_metadata_for_build_wheel whl_basename = backend.build_wheel(metadata_directory, config_settings) File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\sipbuild\api.py", line 46, in build_wheel project = AbstractProject.bootstrap('wheel', File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\sipbuild\abstract_project.py", line 87, in bootstrap project.setup(pyproject, tool, tool_description) File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\sipbuild\project.py", line 584, in setup self.apply_user_defaults(tool) File "C:\Users\\AppData\Local\Temp\pip-install-hq9cgjio\pyqt5_8974b6d63c12423293bc5134d3deaf3a\project.py", line 63, in apply_user_defaults super().apply_user_defaults(tool) File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\pyqtbuild\project.py", line 70, in apply_user_defaults super().apply_user_defaults(tool) File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\sipbuild\project.py", line 236, in apply_user_defaults self.builder.apply_user_defaults(tool) File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\pyqtbuild\builder.py", line 67, in apply_user_defaults raise PyProjectOptionException('qmake', sipbuild.pyproject.PyProjectOptionException [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. PS E:\PythonProject> pip install pyqt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting pyqt5-tools Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b7/70/a25aab849a5e38ae78716acde1f917a14d9d819c8600bbb8cf536781f7c5/pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB) Collecting pyqt5==5.15.4 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/8e/a4/d5e4bf99dd50134c88b95e926d7b81aad2473b47fde5e3e4eac2c69a8942/PyQt5-5.15.4.tar.gz (3.3 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [29 lines of output] Traceback (most recent call last): File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 156, in prepare_metadata_for_build_wheel hook = backend.prepare_metadata_for_build_wheel AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in main() File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 160, in prepare_metadata_for_build_wheel whl_basename = backend.build_wheel(metadata_directory, config_settings) File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\sipbuild\api.py", line 46, in build_wheel project = AbstractProject.bootstrap('wheel', File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\sipbuild\abstract_project.py", line 87, in bootstrap project.setup(pyproject, tool, tool_description) File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\sipbuild\project.py", line 584, in setup self.apply_user_defaults(tool) File "C:\Users\\AppData\Local\Temp\pip-install-ob1rwhpk\pyqt5_7075254d94fa405cb583cb1806e431da\project.py", line 63, in apply_user_defaults super().apply_user_defaults(tool) File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\pyqtbuild\project.py", line 70, in apply_user_defaults super().apply_user_defaults(tool) File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\sipbuild\project.py", line 236, in apply_user_defaults self.builder.apply_user_defaults(tool) File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\pyqtbuild\builder.py", line 67, in apply_user_defaults raise PyProjectOptionException('qmake', sipbuild.pyproject.PyProjectOptionException [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.

下载wheel 终端执行命令报错如下:

PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.15.0.1.7.1-cp35-cp35m-win_amd64.whl ERROR: pyqt5_tools-5.15.0.1.7.1-cp35-cp35m-win_amd64.whl is not a supported wheel on this platform. PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl ERROR: pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl is not a supported wheel on this platform. PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.10.1.1.3-cp35-none-win32.whl ERROR: pyqt5_tools-5.10.1.1.3-cp35-none-win32.whl is not a supported wheel on this platform. PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl ERROR: pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl is not a supported wheel on this platform. PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl ERROR: pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl is not a supported wheel on this platform. PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl ERROR: pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl is not a supported wheel on this platform. PS E:\PythonProject>

一直都是版本不适配的问题。

OK!那就安装低版本的Python解释器!

我依次降低了Python解释器的版本。重复以上操作,还是依旧报错。。。。

算了吧!

放弃吧!

还是用Java开发 用C语言开发吧

。。。

。。。。

。。。。。

还是再努力一下吧,我觉得我悟了

我翻看了很多博客,看到了这样一个解决方案

我尝试了一下。我用Python3.6版本的解释器。我先安装了 wheel

然后再安装PyQT5-tools

然后竟然成功安装了哦!!!

然后 开始配置 Qt Designer

配置 PyUIC

配置PyRCC

OK! 测试一下 打开了。

就是这么完美。

写个Hello World 试试。

创建一个测试项目

打开新窗口

右键代开 Designer

然后创建一个 weidge 窗口。

拖入一个lable显示标签

标签写 Hello World

保存命名为 HelloWorld.iu

用PyUIC打开保存的文件 生成一个 HelloWorld.py的文件

修改一下mian.py 调用HelloWorld.py

import sys import HelloWorld from PyQt5.QtWidgets import QApplication, QMainWindow if __name__ == '__main__': app = QApplication(sys.argv) MainWindow = QMainWindow() ui = HelloWorld.Ui_Form() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_())

执行一下

哦吼。报错了。

放弃

摆烂

这个问题没有找到解决方案 。。。

。。。。。 。。。。。。。

问题总结

前面的PyQT5-tools 一直安装失败是因为 wheel 库没有安装

先安装wheel 库 然后再安装 PyQT5相关的库就没问题了

当然3.10版本的解释器是安装不了了 PyQT5-tools 不支持

我试过了

Python3.8 Python 3.6 是没有问题的

至于最后测试还是报错 执行不了 这个问题

我不知道

库是安装了

Designer 能打开了

最后一步究竟是错在哪了呢?

按照网友们的建议 我把platforms 文件夹放在同级目录了

但是 还是报错的

我敏锐的发现 我这边报错跟网友们的是有差别的 网友们左上角显示的是Designer

我报错的左上角是 Python

大概是这样子吧 所以我看了网友们的方法 还是解决不了我这个问题

就这样吧

您可能感兴趣的内容: ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly pycharm配置深度学习环境:conda env create -f environment.yml报错 python安装cv2包报错解决方法 torch各种版本下载 Python正则表达式一文详解+实例代码展示


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3